home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / sysdeps / mips / setjmp_aux.c < prev    next >
C/C++ Source or Header  |  1993-08-26  |  3KB  |  70 lines

  1. /* Copyright (C) 1992 Free Software Foundation, Inc.
  2.    Contributed by Brendan Kehoe (brendan@zen.org).
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #include <ansidecl.h>
  20. #include <setjmp.h>
  21.  
  22. #ifndef    __GNUC__
  23.   #error This file uses GNU C extensions; you must compile with GCC.
  24. #endif
  25.  
  26. /* This function is only called via the assembly language routine
  27.    __setjmp, which arranges to pass in the stack pointer and the frame
  28.    pointer.  We do things this way because it's difficult to reliably
  29.    access them in C.  */
  30.  
  31. int
  32. DEFUN(__setjmp_aux, (env, sp, fp), __jmp_buf env AND int sp AND int fp)
  33. {
  34.   /* Store the floating point callee-saved registers...  */
  35.   asm volatile ("s.d $f20, %0" : : "m" (env[0].__fpregs[0]));
  36.   asm volatile ("s.d $f22, %0" : : "m" (env[0].__fpregs[1]));
  37.   asm volatile ("s.d $f24, %0" : : "m" (env[0].__fpregs[2]));
  38.   asm volatile ("s.d $f26, %0" : : "m" (env[0].__fpregs[3]));
  39.   asm volatile ("s.d $f28, %0" : : "m" (env[0].__fpregs[4]));
  40.   asm volatile ("s.d $f30, %0" : : "m" (env[0].__fpregs[5]));
  41.  
  42.   /* .. and the PC;  */
  43.   asm volatile ("sw $31, %0" : : "m" (env[0].__pc));
  44.  
  45.   /* .. and the stack pointer;  */
  46.   asm volatile ("sw %1, %0" : : "m" (env[0].__sp), "r" (sp));
  47.  
  48.   /* .. and the FP; it'll be in s8. */
  49.   asm volatile ("sw %1, %0" : : "m" (env[0].__fp), "r" (fp));
  50.  
  51.   /* .. and the GP; */
  52.   asm volatile ("sw $gp, %0" : : "m" (env[0].__gp));
  53.  
  54.   /* .. and the callee-saved registers; */
  55.   asm volatile ("sw $16, %0" : : "m" (env[0].__regs[0]));
  56.   asm volatile ("sw $17, %0" : : "m" (env[0].__regs[1]));
  57.   asm volatile ("sw $18, %0" : : "m" (env[0].__regs[2]));
  58.   asm volatile ("sw $19, %0" : : "m" (env[0].__regs[3]));
  59.   asm volatile ("sw $20, %0" : : "m" (env[0].__regs[4]));
  60.   asm volatile ("sw $21, %0" : : "m" (env[0].__regs[5]));
  61.   asm volatile ("sw $22, %0" : : "m" (env[0].__regs[6]));
  62.   asm volatile ("sw $23, %0" : : "m" (env[0].__regs[7]));
  63.  
  64.   /* .. and finally get and reconstruct the floating point csr.  */
  65.   asm volatile ("cfc1 $2, $31");
  66.   asm volatile ("sw $2, %0" : : "m" (env[0].__fpc_csr));
  67.  
  68.   return 0;
  69. }
  70.